package LearnDataStructure.a_线性结构.队列;

/**
 * @version: 1.0
 * @Author: wuqiu
 * @date: 2023-07-04 13:44
 * @description: LeetcodeLearnAlgorithm -> LearnDataStructure.a_线性结构.队列
 */
public class MyQueueList<T> extends MyLinkedListDouble<T> implements MyQueueAPI<T> {
    @Override
    public void enqueue(T element) {
        super.add(element);
    }

    @Override
    public T dequeue() {
        QueueNode<T> p = super.head.next;
        super.head.next = p.next;
        p.next.pre = super.head;
        p.next = null;
        p.pre = null;
        super.size--;
        return p.data;
    }

    @Override
    public int getSize() {
        return super.size;
    }

    @Override
    public boolean empty() {
        return super.size == 0;
    }

    @Override
    public T peek() {
        return super.head.next.data;
    }
}
